<?php
defined( '_VALID_MOS' ) or die('<script>window.location.href="http://www.kinifurniture.com";</script>');

$adm_functions->is_admin_login();

$icon_description='
<table><tr><td>
	<table cellspacing="0" cellpadding="4" border="0" align="center">
		<tr align="center">
			<td>
				<img src="show_files/open.png" border="0" alt="Pending" />
			</td>
			<td>
				<u>Open</u> album |
			</td>
			<td>
				<img src="show_files/delete.png" border="0" alt="Visible" />
			</td>
			<td>
				<u>Delete</u> album
			</td>
		</tr>
	</table>
</td></tr><tr><td align="center">
	<table cellspacing="0" cellpadding="4" border="0" align="center">
		<tr align="center">
			<td align="center">
				<i>Click on icon to toggle state or execute command.</i>
			</td>
		</tr>
	</table>
</td></tr></table>
';
$adm_menu='
<table width="100%" class="menubar" cellpadding="0" cellspacing="0" border="0">
<tr>
	<td class="menudottedline" width="40%">
		<div class="pathway"><img border="0" src="assets/admin/'.$SITE_LOGO_ADMIN.'"/></div>	</td>
	<td class="menudottedline" align="right">
				<table cellpadding="0" cellspacing="0" border="0" id="toolbar">
		<tr valign="middle" align="center">
				<td>&nbsp;</td>
				<td>
					<a class="toolbar" href="admin.php?show=index">
					<img src="show_files/home.png" alt="Home" name="home" title="Home" align="middle" border="0" />				<br />Home</a>
				</td>
					<td>&nbsp;</td>
					<td>
			<a class="toolbar" href="admin.php?show=add_album">
				<img src="show_files/new_f200.png"  alt="New" name="new" title="New" align="middle" border="0" />				<br />New</a>
		</td>
				</tr>
		</table>
			</td>
</tr>
</table>

<br />
';
if($action=="do_delete"){
	$qrydel="select * from albumdetail where id_album=$id";
//	$selectdel=$dbh->query($qrydel);
	$no_of_gallery=$dbh->num_rows($dbh->query($qrydel));
	if ($no_of_gallery>0)
	{
		echo '<script>alert(\'Album must be empty \');
		window.location.href="admin.php?show=album_manager";</script>';
	} else {
	$qrydel2="select * from album where id_album=$id";
	$selectdel2=$dbh->query($qrydel2);
		while($sqldel2=mysql_fetch_object($selectdel2))
		{
			$img_name2=$sqldel2->img_album;
			if ($img_name2!='')
			@unlink("assets/album/".$img_name2);
			$dbh->query("delete from album where id_album=$id");
			echo '<script>window.location.href="admin.php?show=album_manager";</script>';
		}
	}
}

if($action=="") $action="list";

if($action=="list"){
$section="All";
if(!$page_no)
	$page_no=1;
$MAX=10;
$lastrow=$MAX+$page_no;
if(!next_page)
	$next_page=1;
$next_page=$next_page+1;

$imgSr=$page_no;

		
	$qry="select * from album";
	$lim_min = ($page_no-1)*$MAX;
	$qry2="$qry limit $lim_min,$MAX"; 
	$select=$dbh->query($qry2);
	$TOTAL_RECORDSET=$dbh->num_rows($dbh->query($qry));

	$album_list='';
	$nomor_urut=(($page_no-1)*$MAX);
	while($sqlRow=mysql_fetch_object($select))
	{
	$nomor_urut++;
	$id_album=$sqlRow->id_album;
	$thumbnail=$sqlRow->img_album;
	if ($thumbnail=='') $thumbnail='noimg.png';
	$thumbnail="<a href='admin.php?show=edit_album&id=$id_album'><img border='0' width='75' height='56' src='assets/album/$thumbnail' /></a>";
	$name=$sqlRow->nama_album;
	$album_list.='
		<tr class="row0">
			<td align="center">
				'.$nomor_urut.'
			</td>
			<td align="center">
				'.$thumbnail.'
			</td>
			<td align="center">
				<a href="admin.php?show=gallery_manager&coll='.$id_album.'"><img border="0" src="show_files/open.png" /></a>
			</td>
			<td align="center">
				<a href="admin.php?show=album_manager&action=do_delete&id='.$id_album.'" onclick="return confirm(\'Do you want to delete?\');"><img border="0" src="show_files/delete.png" /></a>
			</td>
			<td align="left"">
				'.$name.'
			</td>
		</tr>
	';
	}
}

//=====================Starting Pagination From Here==========================
	
	//global $my_page_name;
	$my_page_name="./admin.php?show=album_manager";
	include("admin_pagination.inc");

?>